package com.ohuang.baseapp.ohRouter;


import com.ohuang.router_compiler.util.RouterUtil;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.app.Context;

public class OhRouter {


    public static void startAbility(Context context,String path){
        startAbility(context, new Intent(),path);
    }

    public static void startAbility(Context context,Intent intent,String path){
        startAbility(context, intent,new Intent.OperationBuilder() ,path);
    }

    public static void startAbility(Context context, Intent intent,Intent.OperationBuilder builder ,String path){
        Operation operation=builder
                .withAbilityName(RouterUtil.getInstance().getClassNameForPath(path))
                .withBundleName(context.getBundleName())
                .build();
        intent.setOperation(operation);
        context.startAbility(intent,-1);
    }

    public static Class<?> getClassForPath(String path){
        return RouterUtil.getInstance().getClassForPath(path);
    }

    public static String getClassNameForPath(String path){
        return RouterUtil.getInstance().getClassNameForPath(path);
    }

    public static Object getObjectForPath(String path){
        return RouterUtil.getInstance().getObjetForPath(path);
    }


}
